package com.sgb.member.view_model;

import android.text.TextUtils;
import android.util.Log;

import com.sgb.member.MemberConfig;
import com.sgb.member.di.repository.MemberRepertory;
import com.sgb.member.entity.ListMResponse;
import com.sgb.member.entity.MemberBean;
import com.sgb.member.entity.MemberBiddingEntity;
import com.sgb.member.entity.MemberBiddingPreEntity;
import com.sgb.member.entity.MemberCentralizedEntity;
import com.sgb.member.entity.MemberCentralizedFactoryEntity;
import com.sgb.member.entity.MemberCheckStateEntity;
import com.sgb.member.entity.MemberFindPackersEntity;
import com.sgb.member.entity.MemberGoodsListEntity;
import com.sgb.member.entity.MemberLeaseBean;
import com.sgb.member.entity.MemberLogisticsEntity;
import com.sgb.member.entity.MemberPersonBean;
import com.sgb.member.entity.MemberServiceListBean;
import com.sgb.member.entity.MemberTeamBean;
import com.sgb.member.entity.MemberTeamPersonBean;
import com.sgb.member.entity.MemberTenderBean;
import com.sgb.member.entity.MemberTenderListEntity;
import com.sgb.member.ui.fragment.HomeOtherMemberFragment;
import com.swgk.core.base.BaseViewModel;
import com.swgk.core.base.api.APIManager;
import com.swgk.core.base.api.ICallBack;
import com.swgk.core.base.model.entity.BaseEntity;
import com.swgk.core.base.model.entity.H5ReEntity;
import com.swgk.core.base.model.entity.ListResponse;
import com.swgk.core.dialog.DialogHelper;
import com.swgk.core.util.MLog;
import com.swgk.core.util.MToast;
import com.swgk.core.util.SharedPreferenceUtil;
import com.swgk.core.util.StringUtil;
import com.swgk.core.view.areapopup.GoodsSourceLocationEntity;
import com.swgk.core.view.selection.CommonPopEntity;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

public class HomeOtherMemberModel extends BaseViewModel {

    private final HomeOtherMemberFragment fragment;
    private final MemberRepertory mRepertory;
    private final int maxPageSize = 20;
    private int current;

    private CommonPopEntity mAll;

    public HomeOtherMemberModel(HomeOtherMemberFragment fragment, MemberRepertory repertory) {
        this.fragment = fragment;
        this.mRepertory = repertory;

        mAll = new CommonPopEntity();
        mAll.setNo("");
        mAll.setTypeName("全部");
    }

    private void showOrHideDialog(boolean aBoolean) {
        if (aBoolean) {
            if (!DialogHelper.isShowing() && fragment.getActivity() != null) {
                DialogHelper.showProgressDialog(fragment.getActivity(), "数据获取中...");
            }
        } else {
            DialogHelper.dismissProgressDialog();
            fragment.closeRecyclerRefreshing();
        }
    }

    public void loadOtherOneTab(int mCurPos) {
        switch (mCurPos) {
            case 0:
            case 1:
                // 1供方会员
                // 0需方会员
                getMemberTypeList(mCurPos,"");
                break;
            case 2:
                // 会员商品
                getMaterialType();
                break;
            case 3:
                // 会员招采
                getTenderNewSubTypeList();
                break;
            case 4:
                // 会员集采 v1.1.1取消会员集采类型获取改为 需方集采、供方发起、企业专项数据
                getCollectingType();
                break;
            case 5:
                // 会员租赁
                getLeaseType();
                break;
            case 6:
                // 会员工队
                getPackerType();
                break;
            case 7:
                // 会员物流
                getLogisticsType();
                break;
            case 8:
                // 会员企服
                getEnterpriseServicesType();
                break;
            default:
                break;
        }
    }

    public void loadOtherTwoTab(int mCurPos, String mNo) {
        switch (mCurPos) {
            case 0:
            case 1:
                // 供方会员
                // 需方会员
                getMemberTypeSubList(mNo);
                break;
            case 2:
                // 会员商品
                getMaterialSubType(mNo);
                break;
            case 3:
                // 会员招采
                /*int index = TextUtils.isEmpty(mNo) ? 0 : Integer.parseInt(mNo);
                switch (index) {
                    case 0:// 招标报名
                    case 1:// 招标预告
                        getTenderNewSubTypeList();
                        break;
                    case 2:// 竞价采购
                        getBiddingTypeList();
                        break;
                }*/
                // v1.1.1同步会员经营——招采全部数据；筛选显示【一级分类】
                fragment.updateOtherTwoTab(new ArrayList<>());
                break;
            case 4:
                // 会员集采
                int indexCollecting = TextUtils.isEmpty(mNo) ? 0 : Integer.parseInt(mNo);
                switch (indexCollecting) {
                    case 1:// 供方发起
                        getTenderGoodsCategoryAllList();
                        break;
                    case 0:// 需方集采
                    case 2:// 企业专项
                        getCollectingSecondLevelType();
                        break;
                }
                break;
            case 5:
                // 会员租赁
                // getLeaseSubType(mNo);
                break;
            case 6:
                // 会员工队
                getPackerSubType();
                break;
            case 7:
              //物流
                fragment.loadData(false);
                break;
            default:
                break;
        }
    }

    public void loadOtherList(int mCurPos, boolean isLoadMore, String mNo, String mNo11,
                              int comType,String lat,String lon, String mNo12) {
        switch (mCurPos) {
            case 0:
                if (comType == MemberConfig.WEBSITE_FOR_PERSONAL) {
                    // 需方会员
                    getJoinMembers2(isLoadMore, mNo, mNo11, "2"); // 会员关系 1供方 2需方
                }else {
                    // 需方会员
                    getJoinMembers(isLoadMore, "", mNo, mNo11, "", "", "", "", "", "", "", "", "", "");
                }
                break;
            case 1:
                // 供方会员
                if (comType == MemberConfig.WEBSITE_FOR_PERSONAL) {
                    getJoinMembers2(isLoadMore, mNo, mNo11, "1"); // 会员关系 1供方 2需方
                }else {
                    getMyMembers(isLoadMore, "", mNo, mNo11, "", "", "", "", "", "", "", "", "", "");
                }
                break;
            case 2:
                // 会员商品
                getGoodList(isLoadMore, "", mNo, mNo11, "", "", new ArrayList<>(), "", "", "",lat,lon);
                break;
            case 3:
                // 会员招采
                // appV1.1.1需求功能说明 :同步会员经营——招采全部数据；筛选显示【一级分类】
                findTenderingHomeEsPage(isLoadMore, "", mNo);
                break;
            case 4:
                // 会员集采
                int collectionIndex = TextUtils.isEmpty(mNo) ? 0 : Integer.parseInt(mNo);
                switch (collectionIndex) {
                    case 0:
                        groupBuyList(isLoadMore, "", "1", "","","", "","","", "",mNo12);
                        break;
                    case 1:
                        groupBuyGFList(isLoadMore, "", "", "","","", "","","", "",mNo12);
                        break;
                    case 2:
                        groupBuyList(isLoadMore, "", "2", "","","", "","","", "",mNo12);
                        break;
                }
                // 会员集采
                break;
            case 5:
                // 会员租赁
                rentList(isLoadMore, "", mNo, mNo11, "", "", "");
                break;
            case 6:
                // 会员工队
                int teamIndex = TextUtils.isEmpty(mNo) ? 0 : Integer.parseInt(mNo);
                switch (teamIndex) {
                    case 0: // 施工队
                        teamList(isLoadMore, "", "0", mNo11, "", "", "", "", "");
                        break;
                    case 1: // 班组
                        teamList(isLoadMore, "", "1", mNo11, "", "", "", "", "");
                        break;
                    case 3: // 工人
                        teamPriceList(isLoadMore, "", mNo, mNo11, "", "");
                        break;
                }
                break;
            case 7://会员物流
                getFilterSourceList(isLoadMore,mNo);
                break;
            case 8:
                getEnterpriseServiceList(isLoadMore, mNo,mNo11,mNo12);
                break;
            default:
                break;
        }
    }

    //招标大厅-全部
    public void findTenderingHomeEsPage(boolean isLoadMore, String companyName, String mNo1) {
        int currentPage = isLoadMore ? current + 1 : 1;
        showOrHideDialog(true);
        Map<String, Object> map = new HashMap<>();
        map.put("page", currentPage);
        map.put("current", currentPage);
        map.put("limit", maxPageSize);
        map.put("keyword", companyName);
        map.put("type", mNo1);
        map.put("goodsTypeNo", "");
        map.put("verticalType", "");
        map.put("province", "");
        map.put("city", "");
        mRepertory.getApi().tenderAll(map).enqueue(new ICallBack<BaseEntity<ListMResponse<List<MemberTenderBean>>>>() {

            @Override
            public void onFailure(Call<BaseEntity<ListMResponse<List<MemberTenderBean>>>> call, Throwable t) {
                super.onFailure(call, t);
                if (!isLoadMore) {
                    fragment.showEmpty();
                }
            }

            @Override
            public void onSuccess(BaseEntity<ListMResponse<List<MemberTenderBean>>> data) {
                DialogHelper.dismissProgressDialog();
                current = data.getData().getCurrent();
                int total = data.getData().getPages();
                fragment.refreshRecycler(data.getData().getList(), isLoadMore, current >= total);
            }

            @Override
            public void onFinally() {
                showOrHideDialog(false);
            }
        });
    }

    // 会员类型二级
    public void getMemberTypeSubList(String no) {
        showOrHideDialog(true);
        mRepertory.getApi().getMemberTypeSubList(no).enqueue(new ICallBack<BaseEntity<List<CommonPopEntity>>>() {
            @Override
            public void onSuccess(BaseEntity<List<CommonPopEntity>> data) {
                if (data.getData() != null && data.getData().size() > 0) {
                    data.getData().add(0, mAll);
                    fragment.updateOtherTwoTab(data.getData());
                } else {
                    fragment.updateOtherTwoTab(new ArrayList<>());
                }
            }


            @Override
            public void onFailure(Call<BaseEntity<List<CommonPopEntity>>> call, Throwable t) {
                showOrHideDialog(false);
                fragment.updateOtherOneTab(new ArrayList<>());
            }

            @Override
            public void onFinally() {
                showOrHideDialog(false);
            }
        });
    }

    // 会员类型三级
    public void getMemberTypeThreeSubList(String no) {
        showOrHideDialog(true);
        mRepertory.getApi().getMemberTypeSubList(no).enqueue(new ICallBack<BaseEntity<List<CommonPopEntity>>>() {
            @Override
            public void onSuccess(BaseEntity<List<CommonPopEntity>> data) {
                if (data.getData() != null && data.getData().size() > 0) {
                    data.getData().add(0, mAll);
                    fragment.updateOtherThreeTab(data.getData());
                } else {
                    fragment.updateOtherThreeTab(new ArrayList<>());
                }
            }


            @Override
            public void onFailure(Call<BaseEntity<List<CommonPopEntity>>> call, Throwable t) {
                showOrHideDialog(false);
                fragment.updateOtherOneTab(new ArrayList<>());
            }

            @Override
            public void onFinally() {
                showOrHideDialog(false);
            }
        });
    }

    //  根据商品类型->类别->品名
    public void getMaterialSubType( String id) {
        showOrHideDialog(true);
        mRepertory.getApi().getCategoryChoose(id, mRepertory.getAreaCode()).enqueue(new ICallBack<BaseEntity<List<CommonPopEntity>>>() {
            @Override
            public void onSuccess(BaseEntity<List<CommonPopEntity>> data) {
                if (data.getData() != null && data.getData() != null && data.getData().size() > 0) {
                    fragment.updateOtherTwoTab(data.getData());
                } else {
                    fragment.updateOtherTwoTab(new ArrayList<>());
                }
            }

            @Override
            public void onFailure(Call<BaseEntity<List<CommonPopEntity>>> call, Throwable t) {
                showOrHideDialog(false);
                fragment.updateOtherOneTab(new ArrayList<>());
            }

            @Override
            public void onFinally() {
                showOrHideDialog(false);
            }
        });
    }

    // 招标类型 (商品材料、专业工程、劳务分包...)
    public void getTenderNewSubTypeList() {
        showOrHideDialog(true);
        mRepertory.getApi().tenderNewTypeList().enqueue(new ICallBack<BaseEntity<List<CommonPopEntity>>>() {

            @Override
            public void onSuccess(BaseEntity<List<CommonPopEntity>> data) {
                if (data != null && data.getData() != null && data.getData().size() > 0) {
                    data.getData().set(0, new CommonPopEntity("", "全部"));
                    fragment.updateOtherOneTab(data.getData());
                } else {
                    fragment.updateOtherOneTab(new ArrayList<>());
                }
            }

            @Override
            public void onFailure(Call<BaseEntity<List<CommonPopEntity>>> call, Throwable t) {
                showOrHideDialog(false);
                fragment.updateOtherOneTab(new ArrayList<>());
            }

            @Override
            public void onFinally() {
                showOrHideDialog(false);
            }
        });
    }

    // 竞价类型 (商品材料、专业工程、劳务分包...)
    public void getBiddingTypeList() {
        showOrHideDialog(true);
        mRepertory.getApi().biddingTypeList().enqueue(new ICallBack<BaseEntity<List<CommonPopEntity>>>() {

            @Override
            public void onSuccess(BaseEntity<List<CommonPopEntity>> data) {
                if (data.getData() != null && data.getData() != null && data.getData().size() > 0) {
                    data.getData().set(0, new CommonPopEntity("", "全部"));
                    fragment.updateOtherTwoTab(data.getData());
                } else {
                    fragment.updateOtherTwoTab(new ArrayList<>());
                }
            }

            @Override
            public void onFailure(Call<BaseEntity<List<CommonPopEntity>>> call, Throwable t) {
                showOrHideDialog(false);
                fragment.updateOtherOneTab(new ArrayList<>());
            }

            @Override
            public void onFinally() {
                showOrHideDialog(false);
            }
        });
    }

    // 招标类型->获取类别下级所有树形数据
    public void getCollectingSubType(String category) {
        showOrHideDialog(true);
        Call<BaseEntity<List<CommonPopEntity>>> call = null;
        if ("1".equals(category)) { // 商品材料
            call = mRepertory.getApi().getGoodCategory(mRepertory.getAreaCode());
        } else if ("2".equals(category)) { // 机械租赁
            call = mRepertory.getApi().getMachineCategory();
        } else if ("3".equals(category)) { // 设备租赁
            call = mRepertory.getApi().getEquipmentCategory();
        }
        if (call == null) {
            return;
        }
        call.enqueue(new ICallBack<BaseEntity<List<CommonPopEntity>>>() {
            @Override
            public void onSuccess(BaseEntity<List<CommonPopEntity>> data) {
                if (data.getData() != null && data.getData() != null && data.getData().size() > 0) {
                    data.getData().add(0, new CommonPopEntity("", "全部"));
                    fragment.updateOtherTwoTab(data.getData());
                } else {
                    fragment.updateOtherTwoTab(new ArrayList<>());
                }
            }

            @Override
            public void onFailure(Call<BaseEntity<List<CommonPopEntity>>> call, Throwable t) {
                showOrHideDialog(false);
                fragment.updateOtherOneTab(new ArrayList<>());
            }

            @Override
            public void onFinally() {
                showOrHideDialog(false);
            }
        });
    }
    // 集采类型
    public void getCollectingSecondLevelType(){
        showOrHideDialog(true);
        mRepertory.getApi().groupBuyClassList().enqueue(new ICallBack<BaseEntity<List<CommonPopEntity>>>() {
            @Override
            public void onSuccess(BaseEntity<List<CommonPopEntity>> data) {
                if (data.getData() != null && data.getData() != null && data.getData().size() > 0) {
                    data.getData().add(0, mAll);
                    fragment.updateOtherThreeTab(data.getData());
                } else {
                    fragment.updateOtherThreeTab(new ArrayList<>());
                }
            }

            @Override
            public void onFailure(Call<BaseEntity<List<CommonPopEntity>>> call, Throwable t) {
                super.onFailure(call, t);
                fragment.updateOtherThreeTab(new ArrayList<>());
                showOrHideDialog(false);
            }
        });
    }

    // 招标类型->获取类别下级所有树形数据
    public void getTenderGoodsCategoryAllList() {
        showOrHideDialog(true);
        mRepertory.getApi().getGoodCategory(mRepertory.getAreaCode()).enqueue(new ICallBack<BaseEntity<List<CommonPopEntity>>>() {
            @Override
            public void onSuccess(BaseEntity<List<CommonPopEntity>> data) {
                if (data.getData() != null && data.getData() != null && data.getData().size() > 0) {
                        data.getData().add(0, mAll);
                        fragment.updateOtherThreeTab( data.getData());
                }else {
                    fragment.updateOtherThreeTab(new ArrayList<>());
                }
            }
        });
    }


    // 工队-工程分类 type(1 一级分类  type=0 三级分类  type =2 二级分类 type=null  六级分类)
    public void getPackerSubType() {
        showOrHideDialog(true);
            mRepertory.getApi().getCategoryTrees(mRepertory.getAreaCode(), "1").enqueue(new ICallBack<BaseEntity<List<CommonPopEntity>>>() {
                @Override
                public void onSuccess(BaseEntity<List<CommonPopEntity>> data) {
                    DialogHelper.dismissProgressDialog();
                    if (data.getData() != null && data.getData() != null && data.getData().size() > 0) {
                        data.getData().add(0, new CommonPopEntity("", "全部"));
                        fragment.updateOtherTwoTab(data.getData());
                    } else {
                        fragment.updateOtherTwoTab(new ArrayList<>());
                    }
                }

                @Override
                public void onFailure(Call<BaseEntity<List<CommonPopEntity>>> call, Throwable t) {
                    showOrHideDialog(false);
                    fragment.updateOtherOneTab(new ArrayList<>());
                }

                @Override
                public void onFinally() {
                    showOrHideDialog(false);
                }
            });
    }


    // 会员类型
    public void getMemberTypeList(int pos,String businessNo) {
        showOrHideDialog(true);
        // 0 供方 1需方
        mRepertory.getApi().getMemberTypeList2(pos == 0 ? "1" : "0",businessNo).enqueue(new ICallBack<BaseEntity<List<CommonPopEntity>>>() {
            @Override
            public void onSuccess(BaseEntity<List<CommonPopEntity>> data) {
                if (data.getData() != null && data.getData() != null && data.getData().size() > 0) {
                    data.getData().add(0, mAll);
                    fragment.updateOtherOneTab(data.getData());
                } else {
                    showOrHideDialog(false);
                    fragment.updateOtherOneTab(new ArrayList<>());
                }
            }

            @Override
            public void onFailure(Call<BaseEntity<List<CommonPopEntity>>> call, Throwable t) {
                showOrHideDialog(false);
                fragment.updateOtherOneTab(new ArrayList<>());
            }

            @Override
            public void onFinally() {
                showOrHideDialog(false);
            }
        });
    }

    //  根据行业分类->商品类型（industryId:一级类目id，areaCode:省份id)
    public void getMaterialType() {
        showOrHideDialog(true);
        Map<String, Object> map = new HashMap<>();
        map.put("industryId", "");
        map.put("areaCode", mRepertory.getAreaCode());
        mRepertory.getApi().getFirstCategory(map).enqueue(new ICallBack<BaseEntity<List<CommonPopEntity>>>() {
            @Override
            public void onSuccess(BaseEntity<List<CommonPopEntity>> data) {
                if (data.getData() != null && data.getData() != null && data.getData().size() > 0) {
                    fragment.updateOtherOneTab(data.getData());
                } else {
                    fragment.updateOtherOneTab(new ArrayList<>());
                }
            }

            @Override
            public void onFailure(Call<BaseEntity<List<CommonPopEntity>>> call, Throwable t) {
                showOrHideDialog(false);
                fragment.updateOtherOneTab(new ArrayList<>());
            }

            @Override
            public void onFinally() {
                showOrHideDialog(false);
            }
        });
    }

    // 会员招采 v1.1.1 同步会员经营——招采全部数据；筛选显示【一级分类】
    public void getPickType() {
        List<CommonPopEntity> list = new ArrayList<>();
        list.add(new CommonPopEntity("0", "招标报名"));
        list.add(new CommonPopEntity("1", "招标预告"));
        list.add(new CommonPopEntity("2", "竞价采购"));
        fragment.updateOtherOneTab(list);
    }

    // 会员集采
    public void getCollectingType() {
        List<CommonPopEntity> list = new ArrayList<>();
        list.add(new CommonPopEntity("0", "需方集采"));
        list.add(new CommonPopEntity("1", "供方发起"));
        list.add(new CommonPopEntity("2", "企业专项"));
        fragment.updateOtherOneTab(list);
    }

/*    public void getCollectingType() {
        showOrHideDialog(true);
        mRepertory.getApi().groupBuyClassList().enqueue(new ICallBack<BaseEntity<List<CommonPopEntity>>>() {
            @Override
            public void onSuccess(BaseEntity<List<CommonPopEntity>> data) {
                if (data.getData() != null && data.getData() != null && data.getData().size() > 0) {
                    data.getData().add(0, mAll);
                    fragment.updateOtherOneTab(data.getData());
                } else {
                    fragment.updateOtherOneTab(new ArrayList<>());
                }
            }

            @Override
            public void onFailure(Call<BaseEntity<List<CommonPopEntity>>> call, Throwable t) {
                showOrHideDialog(false);
                fragment.updateOtherOneTab(new ArrayList<>());
            }

            @Override
            public void onFinally() {

            }
        });
    }*/

    // 会员租赁
    public void getLeaseType() {
        // 1机械， 2 设备，3车辆，4 房产，5土地，6工厂，7农机
        // "工程机械", "工程设备", "车辆租赁", "房产租赁", "土地租赁", "工厂租赁", "农机租赁"
        showOrHideDialog(true);
        mRepertory.getApi().getRentCategory().enqueue(new ICallBack<BaseEntity<List<CommonPopEntity>>>() {
            @Override
            public void onSuccess(BaseEntity<List<CommonPopEntity>> data) {
                if (data.getData() != null && data.getData() != null && data.getData().size() > 0) {
                    data.getData().add(0, mAll);
                    fragment.updateOtherOneTab(data.getData());
                } else {
                    fragment.updateOtherOneTab(new ArrayList<>());
                }
            }

            @Override
            public void onFailure(Call<BaseEntity<List<CommonPopEntity>>> call, Throwable t) {
                showOrHideDialog(false);
                fragment.updateOtherOneTab(new ArrayList<>());
            }

            @Override
            public void onFinally() {
                showOrHideDialog(false);
            }
        });
    }

    // 会员工队
    public void getPackerType() {
        List<CommonPopEntity> list = new ArrayList<>();
        // 会员工队：同步会员经营——工队【施工队、班组工队】数据；筛选显示【工程 分类一级分类】 移除工种
        list.add(new CommonPopEntity("0", "施工队"));
        list.add(new CommonPopEntity("1", "班组工队"));
        list.add(new CommonPopEntity("3", "工种报价"));
        /*list.add(new CommonPopEntity("2", "工种"));*/
        fragment.updateOtherOneTab(list);
    }

    // 物流货物
    public void getLogisticsType() {
        showOrHideDialog(true);
        mRepertory.getApi().getAllLogisticsGoodsType().enqueue(new ICallBack<BaseEntity<List<CommonPopEntity>>>() {
            @Override
            public void onSuccess(BaseEntity<List<CommonPopEntity>> data) {
                if (data.getData() != null && data.getData() != null && data.getData().size() > 0) {
                    data.getData().add(0, new CommonPopEntity("", "全部"));
                    fragment.updateOtherOneTab(data.getData());
                } else {
                    fragment.updateOtherOneTab(new ArrayList<>());
                }
            }

            @Override
            public void onFailure(Call<BaseEntity<List<CommonPopEntity>>> call, Throwable t) {
                super.onFailure(call, t);
                showOrHideDialog(false);
                fragment.updateOtherOneTab(new ArrayList<>());
            }

            @Override
            public void onFinally() {
                showOrHideDialog(false);
            }
        });
    }

    // 企业服务
    public void getEnterpriseServicesType() {
        showOrHideDialog(true);
        mRepertory.getApi().getAllEnterpriseServicesType().enqueue(new ICallBack<BaseEntity<List<CommonPopEntity>>>() {
            @Override
            public void onSuccess(BaseEntity<List<CommonPopEntity>> data) {
                DialogHelper.dismissProgressDialog();
                if (data.getData() != null && data.getData() != null && data.getData().size() > 0) {
                    data.getData().add(0, new CommonPopEntity("", "全部"));
                    fragment.updateOtherOneTab(data.getData());
                } else {
                    fragment.updateOtherOneTab(new ArrayList<>());
                }
            }

            @Override
            public void onFailure(Call<BaseEntity<List<CommonPopEntity>>> call, Throwable t) {
                super.onFailure(call, t);
                showOrHideDialog(false);
                fragment.updateOtherOneTab(new ArrayList<>());
            }

        });
    }


    // 需方会员
    public void getJoinMembers(boolean isLoadMore, String companyName, String mNo1, String mNo11, String mNo2, String mNo3, String mNo4, String mNo41, String mNo5, String mNo6, String mNo7, String mNo8, String mNo9, String mNo10) {
        showOrHideDialog(true);
        int currentPage = isLoadMore ? current + 1 : 1;
        Map<String, Object> map = new HashMap<>();
        map.put("companyName", companyName); //搜索企业名称
        map.put("memberType", mNo1); //会员类型
        map.put("secondMemberType", mNo11); //会员类型二级
        map.put("companyType", mNo2); //企业类型
        map.put("level", mNo3); //企业等级
        map.put("provinceNo", mNo4); //经营地址 省【add】
        map.put("cityNo", mNo41); //经营地址 市【add】
        map.put("qualificationType", mNo5); //资质类型【add】
        map.put("honourType", mNo6); //荣誉分类【add】
        map.put("assetCategories", mNo7);//固定资产分类【add】
        map.put("knowledgeType", mNo8); //知识产权分类【add】
        map.put("moneyType", mNo9); //单次金额最大【add】
        map.put("isHaveZc", mNo10); //是否有招采信息【add】
        map.put("limit", maxPageSize);
        map.put("page", currentPage);
        mRepertory.getApi().getJoinMembers(map).enqueue(new ICallBack<BaseEntity<ListMResponse<List<MemberBean>>>>() {
            @Override
            public void onSuccess(BaseEntity<ListMResponse<List<MemberBean>>> data) {
                DialogHelper.dismissProgressDialog();
                current = data.getData().getCurrent();
                int total = data.getData().getPages();
                fragment.refreshRecycler(data.getData().getList(), isLoadMore, current >= total);
            }

            @Override
            public void onFailure(Call<BaseEntity<ListMResponse<List<MemberBean>>>> call, Throwable t) {
                super.onFailure(call, t);
                if (!isLoadMore) {
                    fragment.showEmpty();
                }
            }

            @Override
            public void onFinally() {
                showOrHideDialog(false);
            }
        });
    }

    // 供方会员
    public void getMyMembers(boolean isLoadMore, String companyName, String mNo1, String mNo11, String mNo2, String mNo3, String mNo4, String mNo41, String mNo5, String mNo6, String mNo7, String mNo8, String mNo9, String mNo10) {
        int currentPage = isLoadMore ? current + 1 : 1;
        showOrHideDialog(true);
        Map<String, Object> map = new HashMap<>();
        map.put("companyName", companyName); //搜索企业名称
        map.put("memberType", mNo1); //会员类型
        map.put("secondMemberType", mNo11); //会员类型二级
        map.put("companyType", mNo2); //企业类型
        map.put("level", mNo3); //企业等级
        map.put("provinceNo", mNo4); //经营地址 省【add】
        map.put("cityNo", mNo41); //经营地址 市【add】
        map.put("qualificationType", mNo5); //资质类型【add】
        map.put("honourType", mNo6); //荣誉分类【add】
        map.put("assetCategories", mNo7);//固定资产分类【add】
        map.put("knowledgeType", mNo8); //知识产权分类【add】
        map.put("moneyType", mNo9); //单次金额最大【add】
        map.put("isHaveZc", mNo10); //是否有招采信息【add】
        map.put("limit", maxPageSize);
        map.put("page", currentPage);
        mRepertory.getApi().getMembers(map).enqueue(new ICallBack<BaseEntity<ListMResponse<List<MemberBean>>>>() {
            @Override
            public void onSuccess(BaseEntity<ListMResponse<List<MemberBean>>> data) {
                DialogHelper.dismissProgressDialog();
                current = data.getData().getCurrent();
                int total = data.getData().getPages();
                fragment.refreshRecycler(data.getData().getList(), isLoadMore, current >= total);
            }

            @Override
            public void onFailure(Call<BaseEntity<ListMResponse<List<MemberBean>>>> call, Throwable t) {
                super.onFailure(call, t);
                if (!isLoadMore) {
                    fragment.showEmpty();
                }
            }

            @Override
            public void onFinally() {
                showOrHideDialog(false);
            }
        });
    }

    //切换到个人
    // 需方会员
    public void getJoinMembers2(boolean isLoadMore, String mNo1, String mNo11, String relation) {
        showOrHideDialog(true);
        int currentPage = isLoadMore ? current + 1 : 1;
        Map<String, Object> map = new HashMap<>();
        map.put("memberType", mNo1); //会员类型
        map.put("secondMemberType", mNo11); //会员类型二级
        map.put("relation", relation); // 会员关系 1供方 2需方
        int maxPageSize = 10;
        map.put("limit", maxPageSize);
        map.put("page", currentPage);
        mRepertory.getApi().getMemberLeagueCompanyList(map).enqueue(new ICallBack<BaseEntity<ListMResponse<List<MemberPersonBean>>>>() {
            @Override
            public void onSuccess(BaseEntity<ListMResponse<List<MemberPersonBean>>> data) {
                DialogHelper.dismissProgressDialog();
                current = data.getData().getCurrent();
                int total = data.getData().getPages();
                fragment.refreshRecycler(data.getData().getList(), isLoadMore, current >= total);
            }

            @Override
            public void onFailure(Call<BaseEntity<ListMResponse<List<MemberPersonBean>>>> call, Throwable t) {
                super.onFailure(call, t);
                if (!isLoadMore) {
                    fragment.showEmpty();
                }
            }

            @Override
            public void onFinally() {
                showOrHideDialog(false);
            }
        });
    }


    public void getGoodList(boolean isLoadMore, String companyName, String mNo0,
                            String mNo1, String mNo2, String mNo3, List<String> mNo4,
                            String mNo5, String mNo6, String mNo7,String lat,String lon) {

        int currentPage = isLoadMore ? current + 1 : 1;
        showOrHideDialog(true);
        Map<String, Object> map = new HashMap<>();
        map.put("item_storageName", new ArrayList<>());//仓储地
        map.put("key", companyName);// key就是模糊匹配的
        map.put("page", currentPage);
        map.put("limit", maxPageSize);
        map.put("supplierName", "");//供应商名称
        map.put("industryId", "");//行业Id
        map.put("item_cid1", mNo0);//一级类目id
        map.put("item_cid2", mNo1);
        map.put("item_cid", mNo2);//三级类目id
        map.put("customListId", mNo4); //关键字
        map.put("lat", lat);
        map.put("lon", lon);
        if(TextUtils.isEmpty(mNo5)){
            map.put("item_provinceId", mRepertory.getAreaCode());//省份Id
        } else {
            map.put("item_provinceId", mNo5);//省份Id
        }
        map.put("areacode", mRepertory.getAreaCode());
        map.put("distanceSortType", mNo6); //距离排序
        map.put("priceSortType", mNo7);//价格排序
        mRepertory.getApi().getCommodityList(map).enqueue(new ICallBack<BaseEntity<ListMResponse<List<MemberGoodsListEntity>>>>() {
            @Override
            public void onSuccess(BaseEntity<ListMResponse<List<MemberGoodsListEntity>>> data) {
                DialogHelper.dismissProgressDialog();
                current = data.getData().getCurrent();
                int total = data.getData().getPages();
                fragment.refreshRecycler(data.getData().getList(), isLoadMore, current >= total);
            }

            @Override
            public void onFailure(Call<BaseEntity<ListMResponse<List<MemberGoodsListEntity>>>> call, Throwable t) {
                super.onFailure(call, t);
                if (!isLoadMore) {
                    fragment.showEmpty();
                }
            }

            @Override
            public void onFinally() {
                showOrHideDialog(false);
            }
        });
    }

    public void tenderBidderList(boolean isLoadMore, String companyName, String mNo1, String mNo2, String mNo3, String mNo4, String mNo5, String mNo6, String mNo7) {
        int currentPage = isLoadMore ? current + 1 : 1;
        showOrHideDialog(true);
        Map<String, Object> map = new HashMap<>();
        map.put("page", currentPage);
        map.put("limit", maxPageSize);
        map.put("sortMethod", "");
        map.put("keyword", companyName);
        map.put("type", mNo1);
        map.put("goodsType", mNo2);
        map.put("state", mNo3);
        map.put("verticalType", mNo4); //招标方式
        map.put("price", mNo5);
        map.put("province", mNo6);
        map.put("city", mNo7);
        map.put("areacode", mRepertory.getAreaCode());
        mRepertory.getApi().tenderAll(map).enqueue(new ICallBack<BaseEntity<ListMResponse<List<MemberTenderBean>>>>() {
            @Override
            public void onSuccess(BaseEntity<ListMResponse<List<MemberTenderBean>>> data) {
                current = data.getData().getCurrent();
                int total = data.getData().getPages();
                fragment.refreshRecycler(data.getData().getList(), isLoadMore, current >= total);
            }

            @Override
            public void onFailure(Call<BaseEntity<ListMResponse<List<MemberTenderBean>>>> call, Throwable t) {
                super.onFailure(call, t);
                if (!isLoadMore) {
                    fragment.showEmpty();
                }
            }

            @Override
            public void onFinally() {
                showOrHideDialog(false);
            }
        });

    }

    public void tenderPreNoticeList(boolean isLoadMore, String companyName, String mNo1, String mNo2, String mNo3, String mNo4, String mNo5, String mNo6, String mNo7) {
        int currentPage = isLoadMore ? current + 1 : 1;
        showOrHideDialog(true);
        Map<String, Object> map = new HashMap<>();
        map.put("page", currentPage);
        map.put("limit", maxPageSize);
        map.put("memberBidType", "4"); // ？
        map.put("sortMethod", "1"); // 综合排序默认1
        map.put("keyword", companyName);
        map.put("type", mNo1);
        map.put("goodsType", mNo2);
        map.put("applyStartTime", mNo4); // 报名开始时间
        map.put("verticalType", mNo3); //招标方式
        map.put("price", mNo5);
        map.put("province", mNo6);
        map.put("city", mNo7);
        map.put("areacode", mRepertory.getAreaCode());
        mRepertory.getApi().tenderPreNoticeList(map).enqueue(new ICallBack<BaseEntity<ListMResponse<List<MemberBiddingPreEntity>>>>() {
            @Override
            public void onSuccess(BaseEntity<ListMResponse<List<MemberBiddingPreEntity>>> data) {
                DialogHelper.dismissProgressDialog();
                current = data.getData().getCurrent();
                int total = data.getData().getPages();
                fragment.refreshRecycler(data.getData().getList(), isLoadMore, current >= total);
            }

            @Override
            public void onFailure(Call<BaseEntity<ListMResponse<List<MemberBiddingPreEntity>>>> call, Throwable t) {
                super.onFailure(call, t);
                if (!isLoadMore) {
                    fragment.showEmpty();
                }
            }

            @Override
            public void onFinally() {
                showOrHideDialog(false);
            }
        });

    }

    public void tenderBidList(boolean isLoadMore, String companyName, String mNo1, String mNo2, String mNo4, String mNo5, String mNo6, String mNo7) {
        int currentPage = isLoadMore ? current + 1 : 1;
        showOrHideDialog(true);
        Map<String, Object> map = new HashMap<>();
        map.put("page", currentPage);
        map.put("limit", maxPageSize);
        map.put("memberBidType", "");
        map.put("sortMethod", "1"); // 综合排序默认1
        map.put("keyword", companyName);
        map.put("type", mNo1);
        map.put("goodsType", mNo2);
        map.put("time", mNo4); // 发布时间
        map.put("verticalType", ""); //招标方式
        map.put("price", mNo5);
        map.put("province", mNo6);
        map.put("city", mNo7);
        map.put("areacode", mRepertory.getAreaCode());
        mRepertory.getApi().tenderBidList(map).enqueue(new ICallBack<BaseEntity<ListMResponse<List<MemberBiddingEntity>>>>() {
            @Override
            public void onSuccess(BaseEntity<ListMResponse<List<MemberBiddingEntity>>> data) {
                DialogHelper.dismissProgressDialog();
                current = data.getData().getCurrent();
                int total = data.getData().getPages();
                fragment.refreshRecycler(data.getData().getList(), isLoadMore, current >= total);
            }

            @Override
            public void onFailure(Call<BaseEntity<ListMResponse<List<MemberBiddingEntity>>>> call, Throwable t) {
                super.onFailure(call, t);
                if (!isLoadMore) {
                    fragment.showEmpty();
                }
            }

            @Override
            public void onFinally() {
                showOrHideDialog(false);
            }
        });
    }

    public void getBidUrlSetting(String id) {
        showOrHideDialog(true);
        mRepertory.getApi().getUrlSetting("competitivePurchase").enqueue(new ICallBack<BaseEntity<H5ReEntity>>() {
            @Override
            public void onSuccess(BaseEntity<H5ReEntity> data) {
                String url = data.getData().getUrl() + "?id=" + id;
                String lng = SharedPreferenceUtil.getInstance().getString(SharedPreferenceUtil.LONGITUDE_ID, "");
                String lat = SharedPreferenceUtil.getInstance().getString(SharedPreferenceUtil.LATITUDE_ID, "");
                url = url + "&lng=" + lng + "&lat=" + lat;
                MLog.d("api", "H5跳转链接  " + url);
                MemberConfig.getInstance().startWebViewX5(fragment.getActivity(), url, id);
            }

            @Override
            public void onFailureWithEntity(BaseEntity entity) {
                MToast.showToast(fragment.getActivity(), entity.getMsg());
            }
        });
    }

    public void groupBuyList(boolean isLoadMore, String companyName, String mNo0, String mNo1, String mNo2, String mNo3, String mNo4, String mNo6, String mNo7, String mNo8, String mNo12) {
        int currentPage = isLoadMore ? current + 1 : 1;
        showOrHideDialog(true);
        Map<String, Object> map = new HashMap<>();
        map.put("current", currentPage);
        map.put("groupbuyClass", mNo12);
        map.put("page", currentPage);
        map.put("limit", maxPageSize);
        map.put("groupbuyMode", mNo0);//1,需方集采，2企业专项
        mRepertory.getApi().groupBuyList(map).enqueue(new ICallBack<BaseEntity<ListMResponse<List<MemberCentralizedEntity>>>>() {
            @Override
            public void onSuccess(BaseEntity<ListMResponse<List<MemberCentralizedEntity>>> data) {
                DialogHelper.dismissProgressDialog();
                current = data.getData().getCurrent();
                int total = data.getData().getPages();
                fragment.refreshRecycler(data.getData().getList(), isLoadMore, current >= total);
            }

            @Override
            public void onFailure(Call<BaseEntity<ListMResponse<List<MemberCentralizedEntity>>>> call, Throwable t) {
                super.onFailure(call, t);
                if (!isLoadMore) {
                    fragment.showEmpty();
                }
            }

            @Override
            public void onFinally() {
                showOrHideDialog(false);
            }
        });
    }

    public void groupBuyGFList(boolean isLoadMore, String searchKey, String mNo0, String mNo1, String mNo2, String mNo3, String mNo4, String mNo6, String mNo7, String mNo8,String mNo12) {
        int currentPage = isLoadMore ? current + 1 : 1;
        showOrHideDialog(true);
        Map<String, Object> map = new HashMap<>();
        map.put("firstType", mNo12);
        map.put("current", currentPage);
        map.put("page", currentPage);
        map.put("page", currentPage);
        map.put("limit", maxPageSize);
        mRepertory.getApi().getMemberSaleSearch(map).enqueue(new ICallBack<BaseEntity<ListMResponse<List<MemberCentralizedFactoryEntity>>>>() {
            @Override
            public void onSuccess(BaseEntity<ListMResponse<List<MemberCentralizedFactoryEntity>>> data) {
                current = data.getData().getCurrent();
                int total = data.getData().getPages();
                fragment.refreshRecycler(data.getData().getList(), isLoadMore, current >= total);
            }

            @Override
            public void onFailure(Call<BaseEntity<ListMResponse<List<MemberCentralizedFactoryEntity>>>> call, Throwable t) {
                super.onFailure(call, t);
                if (!isLoadMore) {
                    fragment.showEmpty();
                }
            }

            @Override
            public void onFinally() {
                showOrHideDialog(false);
            }
        });
    }

    public void tenderItemClick(MemberTenderBean memberTenderBean) {
        if (memberTenderBean.getBusinessType() == 2) { //1.招标； 2.竞价
            getUrlSetting("competitivePurchase", "?id=" + memberTenderBean.getId());
        } else if (memberTenderBean.getBusinessType() == 1) {
            if (memberTenderBean.getState() == 8) {
                MemberConfig.getInstance().startPickNoticeDetail(fragment.getActivity(), memberTenderBean.getComNo());
            } else {
                MemberConfig.getInstance().startTenderDetails(fragment.getActivity(), memberTenderBean.getId(), 0);
            }
        } else if (memberTenderBean.getBusinessType() == 3) {
            boolean saveBooleanData = SharedPreferenceUtil.getInstance().getSaveBooleanData(SharedPreferenceUtil.PERSON_AUTH, false);
            String companyNo = SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.COMPANY_NO, "");
            String longitude = SharedPreferenceUtil.getInstance().getString(SharedPreferenceUtil.LONGITUDE_ID, "");
            String latitude = SharedPreferenceUtil.getInstance().getString(SharedPreferenceUtil.LATITUDE_ID, "");
            if (TextUtils.isEmpty(longitude)) {
                longitude = "0";
            }
            if (TextUtils.isEmpty(latitude)) {
                latitude = "0";
            }
            String endUrl = "?id=" + memberTenderBean.getId() + "&lng=" + longitude + "&lat=" + latitude + "&type=" + memberTenderBean.getModuleType()+"&isDpprove"+saveBooleanData +"&companyNo"+companyNo;
            getUrlSetting("engineeringProject", endUrl);
        }
    }

    public void getUrlSetting(String param, String endUrl) {
        showOrHideDialog(true);
        mRepertory.getApi().getUrlSetting("competitivePurchase").enqueue(new ICallBack<BaseEntity<H5ReEntity>>() {
            @Override
            public void onSuccess(BaseEntity<H5ReEntity> data) {
                if (data == null || data.getState() == null) {
                    return;
                }
                if (data.getState().equals(APIManager.RESPONSE_OK)) {
                    String url = data.getData().getUrl() + endUrl;
                    MemberConfig.getInstance().startWebViewX5(fragment.getContext(), url);
                } else {
                    MToast.showToast(fragment.getActivity(), data.getMsg());
                }
            }
        });
    }

    public void rentList(boolean isLoadMore, String companyName, String mNo1, String mNo2, String mNo3, String mNo6, String mNo7) {
        int currentPage = isLoadMore ? current + 1 : 1;
        Log.i("xxx","currentPage ->"+currentPage);
        showOrHideDialog(true);
        Map<String, Object> map = new HashMap<>();
        map.put("page", currentPage);
        map.put("limit", maxPageSize);
        map.put("pageSize", maxPageSize);
        map.put("pageNum", currentPage);
        if (TextUtils.isEmpty(mNo3)) {
            mNo3 = "-1";
        }
        map.put("sortWay", mNo3); //排序方式 -1 倒序  ； 1正序
        map.put("keyword", companyName);
        map.put("type", mNo1); //类型 1机械，2 设备， 3 车辆， 4 房产，5土地，6工厂
        map.put("firstCategoryNo", mNo2);//二级分类
        if (TextUtils.isEmpty(mNo6)) {
            map.put("provinceNo", mRepertory.getAreaCode());
        } else {
            map.put("provinceNo", mNo6);
        }
        map.put("cityNo", mNo7);
        map.put("areacode", mRepertory.getAreaCode());
        mRepertory.getApi().rentList(map).enqueue(new ICallBack<BaseEntity<ListMResponse<List<MemberLeaseBean>>>>() {
            @Override
            public void onSuccess(BaseEntity<ListMResponse<List<MemberLeaseBean>>> data) {
                DialogHelper.dismissProgressDialog();
                if (data != null && data.getData() != null){
                    current = data.getData().getCurrent();
                    int total = data.getData().getPages();
                    fragment.refreshRecycler(data.getData().getList(), isLoadMore, current >= total);
                }else{
                    fragment.refreshRecycler(new ArrayList<>(), isLoadMore, false);
                }

            }

            @Override
            public void onFailure(Call<BaseEntity<ListMResponse<List<MemberLeaseBean>>>> call, Throwable t) {
                super.onFailure(call, t);
                if (!isLoadMore) {
                    fragment.showEmpty();
                }
            }

            @Override
            public void onFinally() {
                showOrHideDialog(false);
            }
        });
    }

    public void getRentH5Url(int pos, String id) {
        String name = "";
        if (pos == 1) {
            name = "mechanicsDetail";//机械
        } else if (pos == 2) {
            name = "equipmentDetails";//设备
        } else if (pos == 3) {
            name = "vehicleDetails";//车辆
        } else if (pos == 4) {
            name = "propertyDetails";//房产
        } else if (pos == 5) {
            name = "landDetails";//土地
        } else if (pos == 6) {
            name = "factoryDetails";//工厂
        } else if (pos == 7) {
            name = "farmDetail";//农机
        }
        DialogHelper.showProgressDialog(fragment.getActivity(), null, "加载中...", 0, false, null).setCanceledOnTouchOutside(false);
        mRepertory.getApi().getUrlSetting(name).enqueue(new Callback<BaseEntity<H5ReEntity>>() {
            @Override
            public void onResponse(Call<BaseEntity<H5ReEntity>> call, Response<BaseEntity<H5ReEntity>> response) {
                DialogHelper.dismissProgressDialog();
                if (response.body() == null || response.body().getState() == null) {
                    return;
                }

                if (response.body().getState().equals(APIManager.RESPONSE_OK)) {
                    String url = response.body().getData().getUrl() + "?id=" + id;
                    MemberConfig.getInstance().startWebViewX5(fragment.getActivity(), url);
                } else {
                    MToast.showToast(fragment.getActivity(), response.body().getMsg());
                }
            }

            @Override
            public void onFailure(Call<BaseEntity<H5ReEntity>> call, Throwable t) {
                DialogHelper.dismissProgressDialog();
            }
        });
    }

    // 会员物流
    public void getFilterSourceList(boolean isLoadMore, String goodsModeNo) {
        int currentPage = isLoadMore ? current + 1 : 1;
        showOrHideDialog(true);
        Map<String, Object> map = new HashMap<>();
        map.put("page", currentPage);
        map.put("limit", maxPageSize);
        map.put("goodsModeNo", goodsModeNo); // 货物类型编号
        map.put("pattern", "0"); // 0 普通货源,1 竞价货源
        map.put("areacode", mRepertory.getAreaCode());
        map.put("isApp", 1);
        showOrHideDialog(true);
        mRepertory.getApi().getFilterGoodsSourceList(map).enqueue(new ICallBack<BaseEntity<ListMResponse<List<MemberLogisticsEntity>>>>() {
            @Override
            public void onSuccess(BaseEntity<ListMResponse<List<MemberLogisticsEntity>>> data) {
                DialogHelper.dismissProgressDialog();
                current = data.getData().getCurrent();
                int total = data.getData().getPages();
                fragment.refreshRecycler(data.getData().getList(), isLoadMore, current >= total);
            }

            @Override
            public void onFailure(Call<BaseEntity<ListMResponse<List<MemberLogisticsEntity>>>> call, Throwable t) {
                super.onFailure(call, t);
                DialogHelper.dismissProgressDialog();
            }
        });
    }

    public void getEnterpriseServiceList(boolean isLoadMore, String serviceClass,String mNo11,String mNo12) {
        int currentPage = isLoadMore ? current + 1 : 1;
        showOrHideDialog(true);
        Map<String, Object> map = new HashMap<>();
        map.put("pageSize", currentPage);
        map.put("limit", maxPageSize);
        map.put("asc", false);
        map.put("sortType", 1);
        map.put("serviceClass", serviceClass);
        map.put("serviceCategory", mNo11);
        map.put("serviceItem", mNo12);
        List<String> codes = new ArrayList<>();
        map.put("provinceCode", codes);
        map.put("type", 1); // 发布类型 1 企业 ；2 团队
        mRepertory.getApi().getServiceHallCompanyOrTeamList(map).enqueue(new ICallBack<BaseEntity<ListMResponse<List<MemberServiceListBean>>>>() {
            @Override
            public void onSuccess(BaseEntity<ListMResponse<List<MemberServiceListBean>>> data) {
                DialogHelper.dismissProgressDialog();
                current = currentPage;
                int total = data.getData().getPages();
                fragment.refreshRecycler(data.getData().getList(), isLoadMore, current >= total);
            }

            @Override
            public void onFailure(Call<BaseEntity<ListMResponse<List<MemberServiceListBean>>>> call, Throwable t) {
                super.onFailure(call, t);
                if (!isLoadMore) {
                    fragment.showEmpty();
                }
            }
        });
    }

    public void teamList(boolean isLoadMore, String companyName, String teamType, String mNo1, String mNo2, String mNo3, String mNo4, String mNo6, String mNo7) {
        int currentPage = isLoadMore ? current + 1 : 1;
        showOrHideDialog(true);
        Map<String, Object> map = new HashMap<>();
        map.put("page", currentPage);
        map.put("limit", maxPageSize);
        map.put("teamType", teamType);//团队类型 0 施工队 1班组
        map.put("sortType", "1");//1按照时间 2按照价格
        map.put("firstCategoryNo", mNo1);
        map.put("secondCategoryNo", mNo2);
        map.put("thirdCategoryNo", mNo3);
        map.put("teamSize", mNo4); //团队规模
        map.put("provinceNo", mNo6); //所在地区-省
        map.put("cityNo", mNo7); ////所在地区-市
        mRepertory.getApi().teamList(map).enqueue(new ICallBack<BaseEntity<ListMResponse<List<MemberFindPackersEntity>>>>() {
            @Override
            public void onSuccess(BaseEntity<ListMResponse<List<MemberFindPackersEntity>>> data) {
                DialogHelper.dismissProgressDialog();
                current = data.getData().getCurrent();
                int total = data.getData().getPages();
                fragment.refreshRecycler(data.getData().getList(), isLoadMore, current >= total);
            }

            @Override
            public void onFailure(Call<BaseEntity<ListMResponse<List<MemberFindPackersEntity>>>> call, Throwable t) {
                super.onFailure(call, t);
                if (!isLoadMore) {
                    fragment.showEmpty();
                }
            }

            @Override
            public void onFinally() {
                showOrHideDialog(false);
            }
        });
    }

    //工人
    public void teamPriceList(boolean isLoadMore, String companyName, String mNo1, String mNo4, String mNo6, String mNo7) {
        showOrHideDialog(true);
        int currentPage = isLoadMore ? current + 1 : 1;
        Map<String, Object> map = new HashMap<>();
        map.put("page", currentPage);
        map.put("limit", maxPageSize);
     //   map.put("sortType", "1");//1按照时间 2按照价格
        map.put("workType", ""); //工种类型
        map.put("provinceNo", ""); //所在地区-省
        map.put("cityNo", ""); ////所在地区-市
        map.put("page", currentPage);
        map.put("firstCategoryNo", mNo4);
        mRepertory.getApi().teamPriceList2(map).enqueue(new ICallBack<BaseEntity<ListMResponse<List<MemberTeamPersonBean>>>>() {
            @Override
            public void onSuccess(BaseEntity<ListMResponse<List<MemberTeamPersonBean>>> data) {
                DialogHelper.dismissProgressDialog();
                current = data.getData().getCurrent();
                int total = data.getData().getPages();
                fragment.refreshRecycler(data.getData().getList(), isLoadMore, current >= total);
            }

            @Override
            public void onFailure(Call<BaseEntity<ListMResponse<List<MemberTeamPersonBean>>>> call, Throwable t) {
                super.onFailure(call, t);
                if (!isLoadMore) {
                    fragment.showEmpty();
                }
            }
            @Override
            public void onFinally() {
                showOrHideDialog(false);
            }
        });
    }

    public void getTeamH5Url(String id) {
        DialogHelper.showProgressDialog(fragment.getActivity(), null, "数据加载中...", 0, false, null).setCanceledOnTouchOutside(false);
        mRepertory.getApi().getUrlSetting("teamWorkDetail").enqueue(new Callback<BaseEntity<H5ReEntity>>() {
            @Override
            public void onResponse(Call<BaseEntity<H5ReEntity>> call, Response<BaseEntity<H5ReEntity>> response) {
                DialogHelper.dismissProgressDialog();
                if (response.body() == null || response.body().getState() == null)
                    return;
                if (response.body().getState().equals(APIManager.RESPONSE_OK)) {
                    String url = response.body().getData().getUrl() + "?no=" + id + "&type=0";
                    MLog.d("api", "H5跳转链接  " + url);
                    MemberConfig.getInstance().startWebViewX5(fragment.getActivity(), url);
                } else {
                    MToast.showToast(fragment.getActivity(), response.body().getMsg());
                }
            }

            @Override
            public void onFailure(Call<BaseEntity<H5ReEntity>> call, Throwable t) {
                DialogHelper.dismissProgressDialog();
            }
        });
    }

    public void goodsSourceStatusCheck(String no, int position) {
        HashMap map = new HashMap();
        map.put("no", no);
        mRepertory.getApi().goodsSourceStatusCheck(map).enqueue(new Callback<BaseEntity<MemberCheckStateEntity>>() {
            @Override
            public void onResponse(Call<BaseEntity<MemberCheckStateEntity>> call, Response<BaseEntity<MemberCheckStateEntity>> response) {
                if (response.body() == null) return;

                if (response.body().getState().equals("ok")) {
                    fragment.checkGoodsState(position, response.body().getData());
                }
            }

            @Override
            public void onFailure(Call<BaseEntity<MemberCheckStateEntity>> call, Throwable t) {

            }
        });
    }
}
